# Contributor: TBK <alpin@jjtc.eu>
# Maintainer: Leonardo Arena <rnalrd@alpinelinux.org>
pkgname=protobuf-c
pkgver=1.5.0
pkgrel=0
pkgdesc="Protocol Buffers implementation in C"
url="https://github.com/protobuf-c/protobuf-c"
arch="all"
license="BSD-2-Clause"
depends_dev="$pkgname-compiler=$pkgver-r$pkgrel"
makedepends="autoconf automake libtool abseil-cpp-dev protobuf-dev"
subpackages="$pkgname-compiler $pkgname-dev"
source="https://github.com/protobuf-c/protobuf-c/releases/download/v$pkgver/protobuf-c-$pkgver.tar.gz"

# secfixes:
#   1.4.1-r0:
#     - CVE-2022-33070
#   1.3.2-r0:
#     - CVE-2021-3121

build() {
	CFLAGS="$CFLAGS -flto=auto" \
	CXXFLAGS="$CXXFLAGS -std=c++17 -flto=auto" \
	./configure \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
}

compiler() {
	pkgdesc="Protocol Buffers C compiler"

	amove usr/bin/protoc-c
	amove usr/bin/protoc-gen-c
}

sha512sums="
175c9fc901cab88308730eea982dd62b1e0decdceb80aa53be163f17a440b4acecb834a784beab5cd71186413a322a323f4539758a8727ca51801cf92f9bd3da  protobuf-c-1.5.0.tar.gz
"
